import { request } from "@/utils/service"
import type { MenuInfo, Menu, PageMeta } from "./types/menu"

export function menuAllApi() {
  return request<MenuInfo>({
    url: "/menu/all",
    method: "post",
    data: {
      mode: "all"
    }
  })
}

export function menuUpdateApi(data: { menu: Menu; meta: PageMeta }) {
  return request<ApiResponseData<Menu>>({
    url: "/menu/update",
    method: "post",
    data
  })
}

export function menuSaveApi(data: { menu: Menu; meta: PageMeta }) {
  return request<ApiResponseData<Menu>>({
    url: "/menu/insert",
    method: "post",
    data
  })
}

export function menuDelApi(id: string) {
  return request<ApiResponseData<string>>({
    url: "/menu/del",
    method: "POST",
    data: {
      id
    }
  })
}
